home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / AmiGo.lha / AmiGo / AmiGo.c < prev    next >
C/C++ Source or Header  |  1989-12-12  |  18KB  |  671 lines

  1. /* Go started 4/17/88 by Todd R. Johnson */
  2. /* 8/8/89 cleaned up for first release */
  3. /* Public Domain */
  4.  
  5. #include "go.h"
  6.  
  7. /* From amigainterface.c */
  8. extern void amigainit();
  9. extern void amigaexit();
  10. extern void getinput( short*, short*, short*, short );
  11. extern void placestone();
  12. extern void intrMoveReport( enum bVal, char*, char * );
  13. extern void intrPrisonerReport( short, short );
  14. extern void intrInitScratchArea();
  15. extern void intrPuts( char * );
  16. extern void intrPutshort( short );
  17. extern void intrPutLn();
  18. extern void intrPass( enum bVal );
  19.  
  20. /* From goplayer.c */
  21. extern genMove();
  22. extern char *playReason;
  23. extern short playLevel, showTrees;
  24.  
  25. /* Procedures from this file */
  26. short Connect( enum bVal, short, short, short[4], short[4], short *, short * );
  27. short Maxlibs( short, short );
  28. short Suicide( enum bVal, short, short );
  29. short StoneLibs( short, short );
  30. void EraseMarks();
  31. short GoPlaceStone( enum bVal, short, short );
  32. void GoRemoveStone( short, short );
  33. void MergeGroups( short, short );
  34. void DeleteGroup( short );
  35. void ReEvalGroups( enum bVal, short, short, short );
  36. void GroupCapture( short );
  37. void FixLibs( enum bVal, short, short, short );
  38. void main();
  39. void goRestart();
  40. void RelabelGroups();
  41. short CountAndMarkLibs( short, short );
  42. void CountLiberties( short );
  43. void CheckForEye( short, short, short[4], short, short * );
  44. void CountEyes();
  45. void printGroupReport( short, short );
  46. void goCoord( short, short, char[] );
  47.  
  48. struct bRec goboard[19][19];    /* The main go board */
  49.  
  50. struct Group GroupList[MAXGROUPS];    /* The list of Groups */
  51. short DeletedGroups[4];            /* Codes of deleted groups */
  52.  
  53. short GroupCount = 0;        /* The total number of groups */
  54. short DeletedGroupCount;         /* The total number of groups deleted
  55.                    on a move */
  56. short ko, koX, koY;
  57. short blackPrisoners, whitePrisoners;
  58. short showMoveReason = FALSE, groupInfo = FALSE,
  59.       computerBlack = TRUE, computerWhite = FALSE,
  60.       whitePassed = FALSE, blackPassed = FALSE;
  61.  
  62. enum bVal color;    /* The color to move next */
  63.  
  64. /* Arrays for use when checking around a point */
  65. short xVec[4] = {0, 1, 0, -1};
  66. short yVec[4] = {-1, 0, 1, 0};
  67.  
  68. short member( group, grouplist, cnt )
  69. short group, grouplist[4], cnt;
  70. {
  71.    unsigned short i;
  72.    for (i = 0; i < cnt; i++)
  73.       if (grouplist[i] == group) return TRUE;
  74.    return FALSE;
  75. }
  76.  
  77. /* Does a stone at x, y connect to any groups of color? */
  78. short Connect( color, x, y, fGroups, fCnt, eGroups, eCnt )
  79. enum bVal color;
  80. short x, y;
  81. short fGroups[4], eGroups[4];
  82. short *fCnt, *eCnt;
  83. {
  84.    unsigned short point = 0;
  85.    short tx, ty, total = 0;
  86.    enum bVal opcolor = WHITE;
  87.    *fCnt = 0;
  88.    *eCnt = 0;
  89.    if (color == WHITE) opcolor = BLACK;
  90.    for (point = 0; point <= 3; point++ )  
  91.    {
  92.       tx = x + xVec[point];
  93.       ty = y + yVec[point];
  94.       if (tx >= 0 && tx <= 18 && ty >= 0 && ty <= 18)
  95.          if (goboard[tx][ty].Val == color
  96.              && ! member( goboard[tx][ty].GroupNum, fGroups, *fCnt ))
  97.             {
  98.                fGroups[(*fCnt)++] = goboard[tx][ty].GroupNum;
  99.            total += 1;
  100.         }
  101.          else if (goboard[tx][ty].Val == opcolor
  102.              && ! member( goboard[tx][ty].GroupNum, eGroups, *eCnt ))
  103.             {
  104.                eGroups[(*eCnt)++] = goboard[tx][ty].GroupNum;
  105.            total += 1;
  106.         }
  107.    }
  108.    return total;
  109. }
  110.  
  111. /* Returns the maximum number of liberties for a given intersection */
  112. short Maxlibs( x, y )
  113. short x, y;
  114. {
  115.    short cnt = 4;
  116.    if (x == 0 || x == 18) cnt = cnt - 1;
  117.    if (y == 0 || y == 18) cnt = cnt - 1;
  118.    return cnt;
  119. }
  120.  
  121. /* Determine whether x, y is suicide for color */
  122. short Suicide( color, x, y )
  123. enum bVal color;
  124. short x, y;
  125. {
  126.    enum bVal opcolor = BLACK;
  127.    short friendlycnt, friendlygroups[4], enemycnt, enemygroups[4], total;
  128.    short maxlibs, i, libcnt = 0;
  129.    if (color == BLACK) opcolor = WHITE;
  130.    maxlibs = Maxlibs( x, y );
  131.    total = Connect( color, x, y, friendlygroups, &friendlycnt,
  132.                    enemygroups, &enemycnt);
  133.    if (total < maxlibs) return FALSE;
  134.    /* Check for a capture */
  135.    for (i = 0; i < enemycnt; i++ )
  136.       if (GroupList[enemygroups[i]].liberties == 1) return FALSE;
  137.    for (i = 0; i < friendlycnt; i++ )
  138.       libcnt += GroupList[friendlygroups[i]].liberties - 1;
  139.    if (libcnt != 0) return FALSE;
  140.    return TRUE;
  141. }
  142.    
  143. /* Returns the number of liberties for x, y */
  144. short StoneLibs( x, y )
  145. short x, y;
  146. {
  147.    short cnt = 0, tx, ty;
  148.    unsigned short point;
  149.    for (point = 0; point <= 3; point++)
  150.       {
  151.          tx = x + xVec[point];
  152.      ty = y + yVec[point];
  153.      if (tx >= 0 && tx <= 18 && ty >= 0 && ty <= 18 &&
  154.          goboard[tx][ty].Val == EMPTY)
  155.         cnt++;
  156.       }
  157.    return cnt;
  158. }
  159.    
  160. void EraseMarks()
  161. {
  162.    short x, y;
  163.    for (y = 0; y <= 18; y++)
  164.       for (x = 0; x <= 18; x++)
  165.      goboard[x][y].marked = FALSE;
  166. }
  167.  
  168. /* Place a stone of color at x, y */
  169. short GoPlaceStone( color, x, y )
  170. enum bVal color;
  171. short x, y;
  172. {
  173.    short fgroups[4], egroups[4];    /* group codes surrounding stone */
  174.    short fcnt, ecnt, i;
  175.    short lowest = GroupCount + 1;
  176.  
  177.    DeletedGroupCount = 0;
  178.    if (goboard[x][y].Val != EMPTY) return FALSE;
  179.    if (Suicide( color, x, y )) return FALSE;  /* Illegal move */
  180.    if (ko && koX == x && koY == y) return FALSE;
  181.    ko = FALSE;
  182.    placestone( color, x, y );
  183.    goboard[x][y].Val = color;
  184.    /* Does the new stone connect to any friendly stone(s)? */
  185.    Connect( color, x, y, fgroups, &fcnt, egroups, &ecnt );
  186.    if (fcnt)
  187.    {
  188.       /* Find the connecting friendly group with the lowest code */
  189.       for ( i = 0; i < fcnt; i++ )
  190.          if (fgroups[i] <= lowest) lowest = fgroups[i];
  191.       /* Renumber resulting group */
  192.       /* Raise the stone count of the lowest by one to account for new
  193.          stone */
  194.       goboard[x][y].GroupNum = lowest;
  195.       GroupList[lowest].count += 1;
  196.       for ( i = 0; i < fcnt; i++ )
  197.          if (fgroups[i] != lowest)
  198.         MergeGroups( lowest, fgroups[i] );
  199.       /* Fix the liberties of the resulting group */
  200.       CountLiberties( lowest );        /* Fix up liberties for group */
  201.    }
  202.    else
  203.    {
  204.       /* Isolated stone.  Create new group. */
  205.       GroupCount += 1;
  206.       lowest = GroupCount;
  207.       GroupList[ lowest ].color = color;
  208.       GroupList[ lowest ].count = 1;
  209.       GroupList[ lowest ].internal = 0;
  210.       GroupList[ lowest ].external = StoneLibs( x, y );
  211.       GroupList[ lowest ].liberties = GroupList[ lowest ].external;
  212.       GroupList[ lowest ].eyes = 0;
  213.       GroupList[ lowest ].alive = 0;
  214.       GroupList[ lowest ].territory = 0;
  215.       goboard[x][y].GroupNum = lowest;
  216.    }
  217.    /* Now fix the liberties of enemy groups adjacent to played stone */
  218.    FixLibs( color, x, y, PLACED );  /* Fix the liberties of opcolor */
  219.    ReEvalGroups( color, x, y, lowest );
  220.    RelabelGroups();
  221.    return TRUE;
  222. }
  223.  
  224. /* Remove a stone from the board */
  225. void GoRemoveStone( x, y )
  226. short x, y;
  227. {
  228.    goboard[x][y].Val = EMPTY;
  229.    goboard[x][y].GroupNum = 0;
  230.    removestone( x, y );
  231. }
  232.  
  233. /* Merges two groups -- Renumbers stones and deletes second group from
  234. list.  Fixes stone count of groups.  This does not fix anything else. 
  235. FixLibs must be called to fix liberties, etc. */
  236. void MergeGroups( g1, g2 )
  237. short g1, g2;
  238. {
  239.    short x, y;
  240.    for (y = 0; y <= 18; y++)
  241.       for (x = 0; x <= 18; x++)
  242.          if (goboard[x][y].GroupNum == g2) goboard[x][y].GroupNum = g1;
  243.    GroupList[g1].count += GroupList[g2].count;
  244.    DeleteGroup( g2 );  /* Removes group from GroupList */
  245. }
  246.  
  247. /* Stores a group code to be deleted */
  248. void DeleteGroup( code )
  249. short code;
  250. {
  251.    DeletedGroups[DeletedGroupCount++] = code;
  252. }
  253.  
  254. /* Re-evaluate the groups given the last move.  This assumes that the
  255. last move has been merged into adjoining groups and all liberty counts
  256. are correct.  Handles capture. Checks for Ko.  Keeps track of captured
  257. stones. code is the group number of the stone just played. */
  258. void ReEvalGroups( color, x, y, code )
  259. enum bVal color;
  260. short x, y, code;
  261. {
  262.    short fgroups[4], egroups[4], fcnt, ecnt, i, killcnt = 0, count = 0;
  263.    enum bVal opcolor = BLACK;
  264.    if (color == BLACK) opcolor = WHITE;
  265.    /* Check for capture */
  266.    Connect( color, x, y, fgroups, &fcnt, egroups, &ecnt );
  267.    if (ecnt)
  268.    {
  269.       /* See if any of the groups have no liberties */
  270.       for (i = 0; i < ecnt; i++ )
  271.          if (GroupList[egroups[i]].liberties == 0)
  272.          {
  273.          killcnt += 1;
  274.          count = GroupList[egroups[i]].count;
  275.          GroupCapture( egroups[i] );
  276.      }
  277.    }
  278.    /* Check for ko.  koX and koY are set in GroupCapture above. */
  279.    if (killcnt == 1 && count == 1
  280.        && GroupList[ code  ].count == 1
  281.        && GroupList[ code ].liberties == 1)
  282.            ko = TRUE;
  283.    if (killcnt) intrPrisonerReport( blackPrisoners, whitePrisoners );
  284.    /* Set eye count for groups */
  285.    CountEyes();
  286.    #ifdef DEBUG
  287.    PrintGroupInfo();
  288.    #endif
  289. }
  290.  
  291. /* Remove a captured group from the board and fix the liberties of any
  292.    adjacent groups.  Fixes prisoner count. Sets KoX and KoY */
  293. void GroupCapture( code )
  294. short code;
  295. {
  296.    short x, y;
  297.    if (GroupList[code].color == BLACK)
  298.       blackPrisoners += GroupList[code].count;
  299.    else
  300.       whitePrisoners += GroupList[code].count;
  301.    for (y = 0; y <= 18; y++)
  302.       for( x = 0; x <= 18; x++ )
  303.          if (goboard[x][y].GroupNum == code)
  304.      {
  305.         FixLibs( GroupList[code].color, x, y, REMOVED );
  306.         GoRemoveStone( x, y );
  307.         koX = x; koY = y;
  308.      }
  309.    DeleteGroup( code );
  310. }
  311.  
  312. /* Fix the liberties of groups adjacent to x, y.  move indicates
  313.   whether a stone of color was placed or removed at x, y
  314.   This does not change liberty counts of friendly groups when a stone
  315.   is placed.  Does not do captures. */
  316. void FixLibs( color, x, y, move )
  317. enum bVal color;
  318. short x, y, move;
  319. {
  320.    short fgroups[4], fcnt, egroups[4], ecnt, i;
  321.    enum bVal opcolor = BLACK;
  322.    if (color == BLACK) opcolor = WHITE;
  323.    Connect( color, x, y, fgroups, &fcnt, egroups, &ecnt );
  324.    if (move == PLACED)
  325.       for (i = 0; i < ecnt; i++)
  326.          GroupList[egroups[i]].liberties -= 1;
  327.    else /* Stone removed so increment opcolor */
  328.       for (i = 0; i < ecnt; i++)
  329.          GroupList[egroups[i]].liberties += 1;
  330. }
  331.  
  332. void goRestart()
  333. {
  334. short x, y;
  335.  
  336.    color = BLACK;
  337.    ko = FALSE;
  338.    blackPrisoners = 0;
  339.    whitePrisoners = 0;
  340.    intrPrisonerReport( 0, 0 );
  341.    intrInitScratchArea();
  342.    intrCredits();
  343.    for (y = 0; y <= 18; y++)
  344.        for (x = 0; x <= 18; x++)
  345.           if (goboard[x][y].Val != EMPTY)
  346.        {
  347.              goboard[x][y].Val = EMPTY;
  348.              removestone( x, y );
  349.              }
  350. } /* goRestart */
  351.  
  352. void main()
  353. {
  354.    short msg, x, y, playing = FALSE;
  355.    char *coord = "   ";
  356.  
  357.    playLevel = 7;
  358.    showTrees = FALSE;
  359.    amigainit();
  360.    for (y = 0; y <= 18; y++)
  361.        for (x = 0; x <= 18; x++)
  362.              goboard[x][y].Val = EMPTY;
  363.    goRestart();
  364.  
  365. while (TRUE)
  366. {
  367.    while (! playing)
  368.    {
  369.       getinput( &msg, &x, &y, FALSE );
  370.       switch (msg)
  371.       {
  372.          case INTERSECTIONMSG:
  373.          {
  374.             if (goboard[x][y].Val == EMPTY) 
  375.            GoPlaceStone( BLACK, x, y );
  376.         else if (goboard[x][y].Val == BLACK)
  377.         {
  378.            GoRemoveStone( x, y );
  379.            GoPlaceStone( WHITE, x, y );
  380.         }
  381.         else
  382.            GoRemoveStone( x, y );
  383.         break;
  384.      }
  385.      case RESTARTMSG:
  386.      {
  387.         goRestart();
  388.         break;
  389.      }
  390.          case QUITMSG:
  391.      {
  392.         amigaexit();
  393.         return;
  394.      }
  395.      case PLAYMSG:
  396.      {
  397.         playing = TRUE;
  398.         intrInitScratchArea(); /* Clear initial message */
  399.         break;
  400.      }
  401.       } /* switch */
  402.    }
  403.    while (playing)
  404.    {
  405.       /* Get a move from one of the players */
  406.       if ((color == BLACK && computerBlack) ||
  407.           (color == WHITE && computerWhite))
  408.     /* First see if the user has generated any messages. */
  409.     /* This is needed for Amiga vs. Amiga games */
  410.     {
  411.      getinput( &msg, &x, &y, TRUE ); 
  412.      if (msg)
  413.         switch( msg )
  414.         {
  415.          case RESTARTMSG:
  416.          {
  417.             playing = FALSE;
  418.             goRestart();
  419.             continue;
  420.          }
  421.          case QUITMSG:
  422.          {
  423.             amigaexit();
  424.             return;
  425.          }
  426.         } /* switch */
  427.          if (genMove( color, &x, &y ))
  428.          {
  429.         msg = INTERSECTIONMSG;
  430.         goCoord( x, y, coord );
  431.         intrMoveReport( color, coord, playReason );
  432.      }
  433.          else
  434.         msg = PASSMSG;
  435.       }
  436.       else getinput( &msg, &x, &y, FALSE );
  437.  
  438.       /* Handle the move */
  439.       switch (msg)
  440.       {
  441.          case INTERSECTIONMSG:
  442.          {
  443.             if (goboard[x][y].Val != EMPTY) 
  444.             {
  445.            printGroupReport(x, y);
  446.            break;
  447.         }
  448.             if (GoPlaceStone( color, x, y ))
  449.                if (color == BLACK)
  450.            {
  451.               color = WHITE;
  452.           blackPassed = FALSE;
  453.            }
  454.            else
  455.            {
  456.               color = BLACK;
  457.           whitePassed = FALSE;
  458.            }
  459.             break;
  460.          }
  461.      case PASSMSG:
  462.         if (color == WHITE)
  463.         {
  464.            intrPass( color );
  465.            whitePassed = TRUE;
  466.            if (blackPassed)
  467.            {
  468.               playing = FALSE;
  469.           intrPutLn(); intrPuts( "Game Over" );
  470.           break;
  471.            }
  472.            color = BLACK;
  473.            continue;
  474.         }
  475.         else
  476.         {
  477.            intrPass( color );
  478.            blackPassed = TRUE;
  479.            if (whitePassed)
  480.            {
  481.               playing = FALSE;
  482.           intrPutLn(); intrPuts( "Game Over" );
  483.           break;
  484.            }
  485.            color = WHITE;
  486.            continue;
  487.         }           
  488.      case RESTARTMSG:
  489.      {
  490.         playing = FALSE;
  491.         goRestart();
  492.         break;
  493.      }
  494.      case QUITMSG:
  495.      {
  496.         amigaexit();
  497.         return;
  498.      }
  499.       }
  500.    }
  501. }
  502. }
  503.  
  504. /* if any groups have been deleted as a result of the last move, this
  505.    routine will delete the old group numbers from GroupList and
  506.    reassign group numbers. */
  507. void RelabelGroups()
  508. {
  509.    unsigned short i, j, x, y;
  510.    for (i = 0; i < DeletedGroupCount; i++)
  511.    {
  512.       /* Relabel all higher groups */
  513.       for (y = 0; y <= 18; y++)
  514.          for (x = 0; x <= 18; x++)
  515.             if (goboard[x][y].GroupNum > DeletedGroups[i])
  516.            goboard[x][y].GroupNum = goboard[x][y].GroupNum - 1;
  517.       /* Move the groups down */
  518.       for (y = DeletedGroups[i]; y < GroupCount; y++)
  519.          GroupList[y] = GroupList[y+1];
  520.       /* fix the group numbers stored in the deleted list */
  521.       for (j = i+1; j < DeletedGroupCount; j++)
  522.      if (DeletedGroups[j] > DeletedGroups[i])
  523.           DeletedGroups[j] -= 1;
  524.       GroupCount -= 1;
  525.    }
  526. }
  527.  
  528. /* Returns liberty count for x, y intersection.  Sets marked to true
  529.    for each liberty */
  530. short CountAndMarkLibs( x, y )
  531. short x, y;
  532. {
  533.    short cnt = 0;
  534.    if ((x > 0) && (goboard[x-1][y].Val == EMPTY) 
  535.                     && (goboard[x-1][y].marked == FALSE))
  536.       { cnt++; goboard[x-1][y].marked = TRUE; }
  537.    if ((x < 18) && (goboard[x+1][y].Val == EMPTY)
  538.                && (goboard[x+1][y].marked == FALSE))
  539.       { cnt++; goboard[x+1][y].marked = TRUE; }
  540.    if ((y > 0) && (goboard[x][y-1].Val == EMPTY)
  541.                && (goboard[x][y-1].marked == FALSE))
  542.       { cnt++; goboard[x][y-1].marked = TRUE; }
  543.    if ((y < 18) && (goboard[x][y+1].Val == EMPTY)
  544.                && (goboard[x][y+1].marked == FALSE))
  545.       { cnt++; goboard[x][y+1].marked = TRUE; }
  546.    return cnt;
  547. }
  548.  
  549. /* Determine the number of liberties for a group given the group code
  550.    num */
  551. void CountLiberties( code )
  552. short code;
  553. {
  554.    short x, y, libcnt = 0;
  555.    for (y = 0; y <= 18; y++)
  556.       for (x = 0; x <= 18; x++)
  557.          if (goboard[x][y].GroupNum == code)
  558.         libcnt += CountAndMarkLibs( x, y );
  559.    EraseMarks();
  560.    GroupList[code].liberties = libcnt;
  561. }
  562.  
  563. void CheckForEye( x, y, groups, cnt, recheck )
  564. short x, y, groups[4], cnt, *recheck;
  565. {
  566.    short i;
  567.    for (i = 0; i < (cnt-1); i++)
  568.       if (groups[i] != groups[i+1])
  569.       {
  570.          /* Mark liberty for false eye check */
  571.      goboard[x][y].marked = TRUE;
  572.          (*recheck)++;
  573.      return;
  574.       }
  575.    /* It is an eye */
  576.    GroupList[groups[i]].eyes += 1;
  577. }
  578.    
  579. /* Set the eye count for the groups */
  580. void CountEyes()
  581. {
  582.    short i, x, y, wgroups[4], bgroups[4], wcnt, bcnt, max, cnt, recheck = 0,
  583.          eye;
  584.    for (i = 1; i <= GroupCount; i++)
  585.       GroupList[i].eyes = 0;
  586.    for (y = 0; y <= 18; y++)
  587.       for (x = 0; x <= 18; x++)
  588.       {
  589.          if (goboard[x][y].Val != EMPTY) continue;
  590.      cnt = Connect( WHITE, x, y, wgroups, &wcnt, bgroups, &bcnt );
  591.      max = Maxlibs( x, y );
  592.          if (cnt == max && wcnt == 1 && bcnt == 0)
  593.         GroupList[wgroups[0]].eyes += 1;
  594.      else if (cnt == max && bcnt == 1 && wcnt == 0)
  595.         GroupList[bgroups[0]].eyes += 1;
  596.      else if (cnt == max && ( bcnt == 0 || wcnt == 0 ))
  597.          {
  598.             goboard[x][y].marked = TRUE;
  599.             recheck++;
  600.      }
  601.       }
  602.    /* Now recheck marked liberties to see if two or more one eye
  603.       groups contribute to a false eye */
  604.    if (recheck == 0) return;
  605.    for (y = 0; y <= 18; y++)
  606.       for (x = 0; x <= 18; x++)
  607.          if (goboard[x][y].marked)
  608.      {
  609.         recheck--;
  610.         goboard[x][y].marked = FALSE;
  611.         Connect( WHITE, x, y, wgroups, &wcnt, bgroups, &bcnt );
  612.         /* If all the groups have at least one eye then all the
  613.            groups are safe from capture because of the common
  614.            liberty at x, y */
  615.             eye = TRUE;
  616.         for (i = 0; i < wcnt; i++)
  617.            if (GroupList[wgroups[i]].eyes == 0) eye = FALSE;
  618.             if (eye)
  619.            for (i = 0; i < wcnt; i++)
  620.                GroupList[wgroups[i]].eyes += 1;
  621.         for (i = 0; i < bcnt; i++)
  622.            if (GroupList[bgroups[i]].eyes == 0) eye = FALSE;
  623.             if (eye)
  624.            for (i = 0; i < bcnt; i++)
  625.                GroupList[bgroups[i]].eyes += 1;
  626.             if (recheck == 0) return;
  627.      }
  628. }
  629.  
  630. #ifdef DEBUG
  631. /* Print group information */
  632. PrintGroupInfo()
  633. {
  634.    short i;
  635.    for (i = 1; i <= GroupCount; i++)
  636.       printf( "Group number %d\n\tEyes: %d\nLibs: %d\n", i, GroupList[i].eyes,
  637.                GroupList[i].liberties );
  638. }
  639. #endif
  640.  
  641. void printGroupReport(x, y)
  642. short x, y;
  643. {
  644.    short g;
  645.    if (! groupInfo) return;
  646.    g = goboard[x][y].GroupNum;
  647.    intrInitScratchArea();
  648.    intrPuts( "Group " ); intrPutshort( g ); intrPutLn();
  649.    intrPuts( "Stones: " );
  650.    intrPutshort( GroupList[g].count ); intrPutLn();
  651.    intrPuts( "Libs: " );
  652.    intrPutshort( GroupList[g].liberties );
  653.    intrPutLn();
  654.    intrPuts( "Eyes: " );
  655.    intrPutshort( GroupList[g].eyes );
  656. }
  657.  
  658. char horizontal[] = "191817161514131211109 8 7 6 5 4 3 2 1 ";
  659. char vertical[] = "ABCDEFGHJKLMNOPQRST";
  660.  
  661. /* Takes an x, y board intersection and returns the algebraic name */
  662. void goCoord( x, y, coord )
  663. short x, y;
  664. char coord[];
  665. {
  666.    coord[0] = vertical[x];
  667.    coord[1] = horizontal[2 * y];
  668.    coord[2] = horizontal[2 * y + 1];
  669. }
  670.    
  671.